import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Enemigo1 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Enemigo1 extends Enemigo
{
    /**
     * Act - do whatever the Enemigo1 wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        Aspire w = (Aspire)getWorld();
        MueveEnemigo();
        w.retx(getX());
        Interseccion();
        
       
    }    
    
    /**
     * Se mueve el enemigo
     */
    public void MueveEnemigo()
    {
        int yAux;
        yAux=getY()+1;
        if(yAux >= getWorld().getHeight()-1)
          yAux=0;
        setLocation(getX(),yAux);
        
        }
    
    /**
     * Ahi checa por cada objeto auxiliar si hubo colision con algunos de dicho objectos auxiliares
     */
    public void Interseccion()
    {
        Aspire w = (Aspire)getWorld();
        Actor balap = getOneIntersectingObject(Balapc.class);
        Actor balpo = getOneIntersectingObject(bapc.class);
        Actor bala = getOneIntersectingObject(Balajug.class);
        Actor balapo = getOneIntersectingObject(Balapod.class);
        
        if (balap != null)
        {
           Greenfoot.playSound("hit.wav");
           hit--;
          if(hit<=4)
          {
            w.addScorep(10);
            destroy();
          }
          
           
        }
        if (balpo != null)
        {
           Greenfoot.playSound("hit.wav");
           hit-=3;
          if(hit<=4)
          {
            w.addScorep(10);
            destroy();
          }
          
           
        }
        if (bala!= null)
        {
           Greenfoot.playSound("hit.wav");
           hit--;
          if(hit<=4)
          {
            w.addScore(10);
            destroy();
          }
          
           
        }
        if (balapo!= null)
        {
           Greenfoot.playSound("hit.wav");
           hit-=3;
          if(hit<=4)
          {
            w.addScore(10);
            destroy();
          }
          
           
        }
    }    
        
    }
    
    

